package com.cn.serverline.lineicp.productionLine.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.cn.serverline.lineicp.productionLine.entity.RollingDetails;
import com.cn.serverline.lineicp.productionLine.service.IRollingDetailsService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 滚动计划详情 接口
 *
 * @author 郭明然
 * @since 2024-08-22
 */
@RestController
@ApiResource(name = "滚动计划详情的接口")
public class RollingDetailsController {

    @Resource(name = "RollingDetailsServiceImpl")
    private IRollingDetailsService iRollingDetailsService;

    /**
     * 下载滚动计划模版
     */
    @ApiOperation(value = "下载滚动计划模版")
    @PostResource(name = "下载滚动计划模版", path = "/productionLine/rollingDetails/download")
    public void exportTemplate(HttpServletResponse response) {
        iRollingDetailsService.exportTemplate(response);
    }

    /**
     * 添加滚动计划详情
     */
    @PostResource(name = "添加滚动计划详情", path = "/productionLine/rollingDetails/add")
    public ResponseData<RollingDetails> add(@RequestBody @Validated RollingDetails rollingDetails){
        iRollingDetailsService.add(rollingDetails);
        return new SuccessResponseData<>();
    }

    /**
     * 删除滚动计划详情
     */
    @PostResource(name = "删除滚动计划详情", path = "/productionLine/rollingDetails/delete")
    public ResponseData<?> delete(@RequestBody @Validated RollingDetails  rollingDetails){
        iRollingDetailsService.del(rollingDetails);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑滚动计划详情
     */
    @PostResource(name = "编辑滚动计划详情", path = "/productionLine/rollingDetails/edit")
    public ResponseData<?> edit(@RequestBody @Validated RollingDetails rollingDetails) {
        iRollingDetailsService.edit(rollingDetails);
        return new SuccessResponseData<>();
    }

    /**
     * 分页查询-滚动计划详情列表
     */
    @GetResource(name = "分页查询-滚动计划详情列表", path = "/productionLine/rollingDetails/page")
    public ResponseData<PageResult<RollingDetails>> page(RollingDetails rollingDetails) {
        return new SuccessResponseData<>(iRollingDetailsService.findPage(rollingDetails));
    }

}
